// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
/* 
	{
	    "goods_list": 
	    {
	        "price": 6377,
	        "name": "【XXXX40 Pro】XXXX60 Pro 6G手机",
	        "count": 1,
	        "sku_id": "667b6079fe544b2ae0a3caaa",
	        "sku": "256G+12G"
	    },
	    "status": "待支付",
	    "order_no": "3716463840117"
	}
*/

module.exports = {
	_before: function () { // 通用预处理器

	},
	/**
	 * 获取订单列表
	 */
	getList: async function () {
	  const db = uniCloud.database().collection('uni-pay-orders')
	  return db.get()
	},
	/**
	 * 添加订单
	 */
	add: async function (data) {
	  const db = uniCloud.database().collection('uni-pay-orders')
	  return db.add(data)
	},
	/**
	 * 更新订单状态
	 */
	update: async function (order_id,new_status) {
	  const db = uniCloud.database().collection('uni-pay-orders')
	  return db.where({_id:order_id}).update({status:new_status});
	},
}
